#include <stdio.h>
#include <stdlib.h>

typedef struct btree{
	int val;
	struct btree* left;
	struct btree* right;
}bnode;

//preorder traversal of binary tree
void preorder_traversal(bnode* root){
	if(root != NULL){
		printf("%d ", root->val);
		preorder_traversal(root->left);
		preorder_traversal(root->right);
	}
}

//inorder traversal of binary tree
void inorder_traversal(bnode* root){
	if(root != NULL){
		inorder_traversal(root->left);
		printf("%d ", root->val);
		inorder_traversal(root->right);
	}
}

int main(){
	
	bnode root;
	root.val = 10;

	bnode left;
	left.val = 30;
	bnode leftc;
	leftc.val = 50;
	leftc.left = NULL;
	leftc.right= NULL;

	left.left = &leftc;
	left.right = NULL;

	bnode right;
	right.val = 20;
	right.left = NULL;
	right.right = NULL;

	root.left = &left;
	root.right = &right;

	inorder_traversal(&root);
	printf("\n");
	preorder_traversal(&root);
	printf("\n");
	return 1;
}
